<template>
  <div class="progress-line">
    <div class="progress-bar">
      <div class="progress-bar__outer" :style="{ height: bar_width + 'px'}">
        <div class="progress-bar__inner" :style="barStyle">
        </div>
      </div>
    </div>
    <div class="progress-text">{{percentage}}%</div>
  </div>
</template>

<script>
export default {
  props: {
    percentage: {
        type: Number,
        default: 0,
        required: true,
        validator: val => val >= 0 && val <= 100
      },
      color: {
        type: String,
        default: '#20a0ff'
      },
      bar_width: {
        type: Number,
        default: 6
      }
  },
  computed: {
    barStyle() {
      const style = {};
        style.width = this.percentage + '%'
        style.backgroundColor = this.color
        return style;
    }
  }
}
</script>
<style lang="less" scoped>
.progress-line{
  width: 350px;
  .progress-bar{
    display: inline-block;
    padding-right: 50px;
    margin-right: -55px;
    box-sizing: border-box;
    width: 100%;
    // vertical-align: middle;
  }
  .progress-bar__outer{
    border-radius: 100px;
    background-color: #ebeef5;
    // vertical-align: middle;
    .progress-bar__inner{
      height: 100%;
      border-radius: 100px;
    }
  }
  .progress-text{
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
    line-height: 1;
    color: #606266;
  }
}
</style>
